from pprint import pprint

from django.conf.urls import url
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

from .views import statistical, users, specs, skus, spec_options, spus, skucategories, brands, categories, \
    goodschannels, orders, perms, groups, admins

urlpatterns = [
    # 登录路由
    url(r'^authorizations/$', obtain_jwt_token),
    # url(r'^authorizations/$', ObtainJSONWebToken.as_view()),
    # ----------数据统计----------
    # 用户总量统计
    url(r'^statistical/total_count/$', statistical.UserCountView.as_view()),
    # 当天注册用户总量统计
    url(r'^statistical/day_increment/$', statistical.UserDayCountView.as_view()),
    # 当天登录用户总量统计
    url(r'^statistical/day_active/$', statistical.UserDayActiveCountView.as_view()),
    # 当天下单用户总量统计
    url(r'^statistical/day_orders/$', statistical.UserDayOrderCountView.as_view()),
    # 月增用户总量统计
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    # 商品分类访问量统计
    url(r'^statistical/goods_day_views/$', statistical.GoodsCountView.as_view()),
    # ----------用户管理----------
    url(r'^users/$', users.UsersView.as_view()),
    # ----------simple SPU-----------
    url(r'^goods/simple/$', specs.SpecsView.as_view({'get': 'simple'})),
    # -----------simple SKU-------------
    url(r'^skus/simple/$', skus.SKUImagesView.as_view({'get': 'sku_simple'})),
    # url(r'^skus/images/simple/$', skus.SKUImagesView.as_view({'get': 'sku_simple'})),
    url(r'^goods/specs/simple/$', spec_options.Spec_OptionsView.as_view({'get': 'simplespuspecs'})),
    # SKU三级分类数据
    url(r'^skus/categories/$', skucategories.SKUCategoriesViews.as_view()),
    # spu下所有可选规格型号
    url(r'^goods/(?P<pk>\d+)/specs/$', spus.SPUSpecsViews.as_view()),
    url(r'^goods/images/$', spus.SPUView.as_view({'post': 'images'})),
    # 品牌简版展示, id,name
    url(r'^goods/brands/simple/$', brands.BrandsView.as_view({'get': 'simple'})),
    # 商品分类数据
    url(r'^goods/channel/categories/(?P<pk>\d+)?/?$', categories.CategoriesView.as_view()),
    # 获取一级分类
    url(r'^goods/categories/$', categories.CategoriesView.as_view()),
    # 获取频道分组信息
    url(r'goods/channel_types/', goodschannels.GoodsChannelView.as_view({'get': 'channel_group'})),
    # 订单列表
    url(r'^orders/$', orders.OrderListView.as_view()),
    # 单一订单数据
    url(r'^orders/(?P<pk>\d+)/$', orders.OrderView.as_view()),
    # 修改订单状态
    url(r'^orders/(?P<pk>\d+)/status/$', orders.OrderStatusView.as_view()),
    # 权限类型(可操作的model名称)
    url(r'^permission/content_types/$', perms.PermsView.as_view({'get': 'content_types'})),
    # 权限池
    url(r'^permission/simple/$', groups.GroupsView.as_view({'get': 'simple'})),
    # 用户组池
    url(r'^permission/groups/simple/$', admins.AdminsView.as_view({'get': 'simple'}))
]

router = DefaultRouter()
# --------------------specs SPU规格表管理---------------------------
router.register('goods/specs', specs.SpecsView, base_name='specs')
# --------------------SKU图片管理管理---------------------------
router.register('skus/images', skus.SKUImagesView, base_name='sku_images')
# --------------------SKU管理管理---------------------------
router.register('skus', skus.SKUView, base_name='skus')
# --------------------规格-型号详细表---------------------------
# specs/options/?page=1&pagesize=10
router.register('specs/options', spec_options.Spec_OptionsView, base_name='spec_options')
# --------------------商品品牌管理---------------------------
router.register('goods/brands', brands.BrandsView, base_name='brands')
# --------------------频道管理---------------------------
router.register('goods/channels', goodschannels.GoodsChannelView, base_name='goods_channels')
# --------------------SPU管理管理---------------------------
router.register('goods', spus.SPUView, base_name='spus')
# --------------------perms权限管理---------------------------
router.register('permission/perms', perms.PermsView, base_name='perms')
# --------------------权限组管理---------------------------
router.register('permission/groups', groups.GroupsView, base_name='groups')
# --------------------管理员管理---------------------------
router.register('permission/admins', admins.AdminsView, base_name='admins')

pprint(router.urls)
urlpatterns += router.urls
